<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="viewport" content="height=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <title></title>
    <style>
        *{margin:0;padding:0}
        .add_order{
            width:100%;
            height:auto;
            overflow: hidden;
        }
        .regTop{
            width: 100%;
            line-height: 30px;
            text-align: center;
            background: #50B4F9;
            overflow: hidden;
        }
        .regTop a{
            width: 20%;
            line-height: 30px;
            display: block;
            float: left;
            text-align: left;
            font-weight: 700;
            text-decoration: none;
        }
        .regTop span{
            width: 70%;
            line-height: 30px;
            display: block;
            float: right;
            font-weight: 700;
            text-align: left;
        }
        .message{
            width:100%;
            height:auto;
            padding:1%;
        }
        .message input{
            width:98%;
            margin:2% 0px;
            border:2px dotted #ccc;
            height:30px;
            text-indent: 2%;
            border-radius: 25px;
        }
        .message select{
            width:98%;
            margin:3% 0px;
            border:2px dotted #ccc;
            height:30px;
            text-indent: 1%;
            border-radius: 25px;
        }
        .message textarea{
            margin:0 auto;
            width:97%;
            margin:5% 0px;
            border:2px dotted #ccc;
            height:50px;
            text-indent: 5px;
        }
        div.submit{
            width:99%;
            text-align: center;
            line-height: 30px;
            border-radius: 30px;
            background: #50B4F9;
        }
    </style>
</head>
<body>
    <div class="add_order">
        <div class="regTop">
            <span>&nbsp;&nbsp;下单</span>
            <a class="back" href="index.html">&lt;返回</a>
        </div>
        <div class="content">
            <form action="" id="order">
                <div class="message">
                    <input type="text"  name="name" placeholder="收件人"  required/>
                    <input type="text" name="phone" placeholder="收件人手机号" pattern="[0-9]{11}" required/>
                    <select type="text" name="type" placeholder="商品种类">
                        <option value="1">爱媛大果</option>
                        <option value="2">脐橙大果</option>
                    </select>
                    <input type="text" name="num" value="1" placeholder="商品数量"  required/>
                    <textarea name="address" placeholder="收件人地址" required></textarea>
                    <div class="submit" type="button" onclick="addOrder('{:url("index/index/addOrder")}','order')">下单</div>
                </div>

            </form>
        </div>
    </div>
</body>
</html>
<script src="__STATIC__/js/jquery.min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script>
    function addOrder(url,formid)
    {
        var data = $("#"+formid).serialize();
        if(!data){
            layer.msg('请输入收货人/电话/商品',{'icon':5});
            return false;
        }
        $.ajax({
            url:url,
            type:'post',
            data:data,
            success:function(d){
                var d = JSON.parse(d);
                if(d.code==1){
                    layer.msg('下单成功',{'icon':6});
                }else{
                    layer.msg('下单失败',{'icon':5});
                }
            },
            error:function(d){
                layer.msg('出错了~~~',{'icon':5});
            }
        })
    }

</script>